<?php
require_once __DIR__ . '/config/database.php';
require_once __DIR__ . '/src/controllers/BookmarkController.php';

$bookmarkController = new BookmarkController($conn);
$bookmarks = $bookmarkController->getAll();

foreach ($bookmarks as $bookmark) {
    if (empty($bookmark['imgurl'])) {
        $imgurl = $bookmarkController->getFaviconOrGenerateIcon($bookmark['url'], $bookmark['title']);
        $bookmarkController->updateImgUrl($bookmark['id'], $imgurl);
    }
}

echo "所有书签的图标已更新。";